import math
def add(num1,num2):
    return num1+num2
def sub(num1,num2):
    return num1-num2
def mul(num1,num2): 
    return num1*num2
def div(num1,num2):
    if num2 == 0:
        return "除数不能为0"
    else:
        return num1 / num2
def logab(a,b):
    if a <= 0 or b <= 0:
        return "对数运算的底数和真数必须大于0"
    else:
        return math.log(a, b)
def main():
    flag=True
    while flag:
        print("1.加法")
        print("2.减法")
        print("3.乘法")
        print("4.除法")
        print("5.对数")
        print("6.退出")
        if (int(input("请输入你要进行复数运算(1)还是实数运算(2):\n")))==1:
            num1=complex(input("请输入第一个数字(例如:1+2j):"))
            num2=complex(input("请输入第二个数字(例如:3+4j):"))
        else:
            num1 = float(input("请输入第一个数字:"))
            num2 = float(input("请输入第二个数字:"))
        choice = int(input("请输入你的选择："))
        if choice == 6:
            break
        elif choice < 1 or choice > 6:
            print("无效的输入")
            continue
        elif choice == 1:
            print("结果是：",add(num1,num2))
        elif choice == 2:
            print("结果是：",sub(num1,num2))
        elif choice == 3:
            print("结果是：",mul(num1,num2))
        elif choice == 4:
            print("结果是：",div(num1,num2))
        elif choice == 5:
            print("结果是：",logab(num1,num2))
        else:
            print("无效的输入")
main()